package main

import "fmt"

func main() {
	fmt.Println(findSubsequences([]int{4, 6, 7, 7}))
}
func findSubsequences(nums []int) [][]int {
	var res [][]int
	var list []int
	var helper func(list []int, index int)
	helper = func(list []int, index int) {
		if len(list) >= 2 {
			tmp := make([]int, len(list))
			copy(tmp, list)
			res = append(res, tmp)
		}

		if index == len(nums) {
			return
		}
		used := make(map[int]bool)
		for i := index; i < len(nums); i++ {
			if used[nums[i]] {
				continue
			}
			if len(list) > 0 && nums[i] < list[len(list)-1] {
				continue
			}
			list = append(list, nums[i])
			used[nums[i]] = true
			helper(list, i+1)
			list = list[:len(list)-1]
		}
	}
	helper(list, 0)
	return res
}
